1 /* 2 * This file is part of gtkD. 3 * 4 * gtkD is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License 6 * as published by the Free Software Foundation; either version 3 7 * of the License, or (at your option) any later version, with 8 * some exceptions, please read the COPYING file. 9 * 10 * gtkD is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public License 16 * along with gtkD; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 */ 19 20 // generated automatically - do not change 21 // find conversion definition on APILookup.txt 22 // implement new conversion functionalities on the wrap.utils pakage 23 24 25 module pango.PgLayoutIter; 26 27 private import gobject.ObjectG; 28 private import linker.Loader; 29 private import pango.PgLayout; 30 private import pango.PgLayoutLine; 31 private import pango.c.functions; 32 public import pango.c.types; 33 34 35 /** 36 * A `PangoLayoutIter` can be used to iterate over the visual 37 * extents of a `PangoLayout`. 38 * 39 * To obtain a `PangoLayoutIter`, use [method@Pango.Layout.get_iter]. 40 * 41 * The `PangoLayoutIter` structure is opaque, and has no user-visible fields. 42 */ 43 public class PgLayoutIter 44 { 45 /** the main Gtk struct */ 46 protected PangoLayoutIter* pangoLayoutIter; 47 protected bool ownedRef; 48 49 /** Get the main Gtk struct */ 50 public PangoLayoutIter* getPgLayoutIterStruct(bool transferOwnership = false) 51 { 52 if (transferOwnership) 53 ownedRef = false; 54 return pangoLayoutIter; 55 } 56 57 /** the main Gtk struct as a void* */ 58 protected void* getStruct() 59 { 60 return cast(void*)pangoLayoutIter; 61 } 62 63 /** 64 * Sets our main struct and passes it to the parent class. 65 */ 66 public this (PangoLayoutIter* pangoLayoutIter, bool ownedRef = false) 67 { 68 this.pangoLayoutIter = pangoLayoutIter; 69 this.ownedRef = ownedRef; 70 } 71 72 ~this () 73 { 74 if ( Linker.isLoaded(LIBRARY_PANGO[0]) && ownedRef ) 75 pango_layout_iter_free(pangoLayoutIter); 76 } 77 78 79 /** */ 80 public static GType getType() 81 { 82 return pango_layout_iter_get_type(); 83 } 84 85 /** 86 * Determines whether @iter is on the last line of the layout. 87 * 88 * Returns: %TRUE if @iter is on the last line 89 */ 90 public bool atLastLine() 91 { 92 return pango_layout_iter_at_last_line(pangoLayoutIter) != 0; 93 } 94 95 /** 96 * Copies a `PangoLayoutIter`. 97 * 98 * Returns: the newly allocated `PangoLayoutIter` 99 * 100 * Since: 1.20 101 */ 102 public PgLayoutIter copy() 103 { 104 auto __p = pango_layout_iter_copy(pangoLayoutIter); 105 106 if(__p is null) 107 { 108 return null; 109 } 110 111 return ObjectG.getDObject!(PgLayoutIter)(cast(PangoLayoutIter*) __p, true); 112 } 113 114 /** 115 * Frees an iterator that's no longer in use. 116 */ 117 public void free() 118 { 119 pango_layout_iter_free(pangoLayoutIter); 120 ownedRef = false; 121 } 122 123 /** 124 * Gets the Y position of the current line's baseline, in layout 125 * coordinates. 126 * 127 * Layout coordinates have the origin at the top left of the entire layout. 128 * 129 * Returns: baseline of current line 130 */ 131 public int getBaseline() 132 { 133 return pango_layout_iter_get_baseline(pangoLayoutIter); 134 } 135 136 /** 137 * Gets the extents of the current character, in layout coordinates. 138 * 139 * Layout coordinates have the origin at the top left of the entire layout. 140 * 141 * Only logical extents can sensibly be obtained for characters; 142 * ink extents make sense only down to the level of clusters. 143 * 144 * Params: 145 * logicalRect = rectangle to fill with 146 * logical extents 147 */ 148 public void getCharExtents(out PangoRectangle logicalRect) 149 { 150 pango_layout_iter_get_char_extents(pangoLayoutIter, &logicalRect); 151 } 152 153 /** 154 * Gets the extents of the current cluster, in layout coordinates. 155 * 156 * Layout coordinates have the origin at the top left of the entire layout. 157 * 158 * Params: 159 * inkRect = rectangle to fill with ink extents 160 * logicalRect = rectangle to fill with logical extents 161 */ 162 public void getClusterExtents(out PangoRectangle inkRect, out PangoRectangle logicalRect) 163 { 164 pango_layout_iter_get_cluster_extents(pangoLayoutIter, &inkRect, &logicalRect); 165 } 166 167 /** 168 * Gets the current byte index. 169 * 170 * Note that iterating forward by char moves in visual order, 171 * not logical order, so indexes may not be sequential. Also, 172 * the index may be equal to the length of the text in the 173 * layout, if on the %NULL run (see [method@Pango.LayoutIter.get_run]). 174 * 175 * Returns: current byte index 176 */ 177 public int getIndex() 178 { 179 return pango_layout_iter_get_index(pangoLayoutIter); 180 } 181 182 /** 183 * Gets the layout associated with a `PangoLayoutIter`. 184 * 185 * Returns: the layout associated with @iter 186 * 187 * Since: 1.20 188 */ 189 public PgLayout getLayout() 190 { 191 auto __p = pango_layout_iter_get_layout(pangoLayoutIter); 192 193 if(__p is null) 194 { 195 return null; 196 } 197 198 return ObjectG.getDObject!(PgLayout)(cast(PangoLayout*) __p); 199 } 200 201 /** 202 * Obtains the extents of the `PangoLayout` being iterated over. 203 * 204 * Params: 205 * inkRect = rectangle to fill with ink extents 206 * logicalRect = rectangle to fill with logical extents 207 */ 208 public void getLayoutExtents(out PangoRectangle inkRect, out PangoRectangle logicalRect) 209 { 210 pango_layout_iter_get_layout_extents(pangoLayoutIter, &inkRect, &logicalRect); 211 } 212 213 /** 214 * Gets the current line. 215 * 216 * Use the faster [method@Pango.LayoutIter.get_line_readonly] if 217 * you do not plan to modify the contents of the line (glyphs, 218 * glyph widths, etc.). 219 * 220 * Returns: the current line 221 */ 222 public PgLayoutLine getLine() 223 { 224 auto __p = pango_layout_iter_get_line(pangoLayoutIter); 225 226 if(__p is null) 227 { 228 return null; 229 } 230 231 return ObjectG.getDObject!(PgLayoutLine)(cast(PangoLayoutLine*) __p); 232 } 233 234 /** 235 * Obtains the extents of the current line. 236 * 237 * Extents are in layout coordinates (origin is the top-left corner 238 * of the entire `PangoLayout`). Thus the extents returned by this 239 * function will be the same width/height but not at the same x/y 240 * as the extents returned from [method@Pango.LayoutLine.get_extents]. 241 * 242 * Params: 243 * inkRect = rectangle to fill with ink extents 244 * logicalRect = rectangle to fill with logical extents 245 */ 246 public void getLineExtents(out PangoRectangle inkRect, out PangoRectangle logicalRect) 247 { 248 pango_layout_iter_get_line_extents(pangoLayoutIter, &inkRect, &logicalRect); 249 } 250 251 /** 252 * Gets the current line for read-only access. 253 * 254 * This is a faster alternative to [method@Pango.LayoutIter.get_line], 255 * but the user is not expected to modify the contents of the line 256 * (glyphs, glyph widths, etc.). 257 * 258 * Returns: the current line, that should not be 259 * modified 260 * 261 * Since: 1.16 262 */ 263 public PgLayoutLine getLineReadonly() 264 { 265 auto __p = pango_layout_iter_get_line_readonly(pangoLayoutIter); 266 267 if(__p is null) 268 { 269 return null; 270 } 271 272 return ObjectG.getDObject!(PgLayoutLine)(cast(PangoLayoutLine*) __p); 273 } 274 275 /** 276 * Divides the vertical space in the `PangoLayout` being iterated over 277 * between the lines in the layout, and returns the space belonging to 278 * the current line. 279 * 280 * A line's range includes the line's logical extents. plus half of the 281 * spacing above and below the line, if [method@Pango.Layout.set_spacing] 282 * has been called to set layout spacing. The Y positions are in layout 283 * coordinates (origin at top left of the entire layout). 284 * 285 * Note: Since 1.44, Pango uses line heights for placing lines, and there 286 * may be gaps between the ranges returned by this function. 287 * 288 * Params: 289 * y0 = start of line 290 * y1 = end of line 291 */ 292 public void getLineYrange(out int y0, out int y1) 293 { 294 pango_layout_iter_get_line_yrange(pangoLayoutIter, &y0, &y1); 295 } 296 297 /** 298 * Gets the current run. 299 * 300 * When iterating by run, at the end of each line, there's a position 301 * with a %NULL run, so this function can return %NULL. The %NULL run 302 * at the end of each line ensures that all lines have at least one run, 303 * even lines consisting of only a newline. 304 * 305 * Use the faster [method@Pango.LayoutIter.get_run_readonly] if you do not 306 * plan to modify the contents of the run (glyphs, glyph widths, etc.). 307 * 308 * Returns: the current run 309 */ 310 public PangoLayoutRun* getRun() 311 { 312 return pango_layout_iter_get_run(pangoLayoutIter); 313 } 314 315 /** 316 * Gets the Y position of the current run's baseline, in layout 317 * coordinates. 318 * 319 * Layout coordinates have the origin at the top left of the entire layout. 320 * 321 * The run baseline can be different from the line baseline, for 322 * example due to superscript or subscript positioning. 323 * 324 * Since: 1.50 325 */ 326 public int getRunBaseline() 327 { 328 return pango_layout_iter_get_run_baseline(pangoLayoutIter); 329 } 330 331 /** 332 * Gets the extents of the current run in layout coordinates. 333 * 334 * Layout coordinates have the origin at the top left of the entire layout. 335 * 336 * Params: 337 * inkRect = rectangle to fill with ink extents 338 * logicalRect = rectangle to fill with logical extents 339 */ 340 public void getRunExtents(out PangoRectangle inkRect, out PangoRectangle logicalRect) 341 { 342 pango_layout_iter_get_run_extents(pangoLayoutIter, &inkRect, &logicalRect); 343 } 344 345 /** 346 * Gets the current run for read-only access. 347 * 348 * When iterating by run, at the end of each line, there's a position 349 * with a %NULL run, so this function can return %NULL. The %NULL run 350 * at the end of each line ensures that all lines have at least one run, 351 * even lines consisting of only a newline. 352 * 353 * This is a faster alternative to [method@Pango.LayoutIter.get_run], 354 * but the user is not expected to modify the contents of the run (glyphs, 355 * glyph widths, etc.). 356 * 357 * Returns: the current run, that 358 * should not be modified 359 * 360 * Since: 1.16 361 */ 362 public PangoLayoutRun* getRunReadonly() 363 { 364 return pango_layout_iter_get_run_readonly(pangoLayoutIter); 365 } 366 367 /** 368 * Moves @iter forward to the next character in visual order. 369 * 370 * If @iter was already at the end of the layout, returns %FALSE. 371 * 372 * Returns: whether motion was possible 373 */ 374 public bool nextChar() 375 { 376 return pango_layout_iter_next_char(pangoLayoutIter) != 0; 377 } 378 379 /** 380 * Moves @iter forward to the next cluster in visual order. 381 * 382 * If @iter was already at the end of the layout, returns %FALSE. 383 * 384 * Returns: whether motion was possible 385 */ 386 public bool nextCluster() 387 { 388 return pango_layout_iter_next_cluster(pangoLayoutIter) != 0; 389 } 390 391 /** 392 * Moves @iter forward to the start of the next line. 393 * 394 * If @iter is already on the last line, returns %FALSE. 395 * 396 * Returns: whether motion was possible 397 */ 398 public bool nextLine() 399 { 400 return pango_layout_iter_next_line(pangoLayoutIter) != 0; 401 } 402 403 /** 404 * Moves @iter forward to the next run in visual order. 405 * 406 * If @iter was already at the end of the layout, returns %FALSE. 407 * 408 * Returns: whether motion was possible 409 */ 410 public bool nextRun() 411 { 412 return pango_layout_iter_next_run(pangoLayoutIter) != 0; 413 } 414 }